<?php

namespace app\admin\model\language;

use app\logic\language\LangLogic;
use think\Model;

/**
 * Translate
 */
class Translate extends Model
{
    // 表名
    protected $name = 'language_translate';

    // 自动写入时间戳字段
    protected $autoWriteTimestamp = true;


    public function language(): \think\model\relation\BelongsTo
    {
        return $this->belongsTo(\app\admin\model\Language::class, 'language_id', 'id');
    }

    public function languageKeywords(): \think\model\relation\BelongsTo
    {
        return $this->belongsTo(\app\admin\model\language\Keywords::class, 'language_keywords_id', 'id');
    }

    protected static function onAfterWrite($model): void
    {
        LangLogic::clearLangCache();
    }
}